#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

int main()
{
    int money = 0;
    int rest = 0;
    int mom = 0;
    int ans = 0;
    for (int i = 1; i <= 12; i++)
    {
        cin >> money;
        if (ans < 0)
            ;
        else if (rest + 300 - money < 0)
            ans = -i;
        else
        {
            mom += (rest + 300 - money) / 100;
            rest = (rest + 300 - money) % 100;
        }
    }
    if (ans == 0)
        cout << mom * 120 + rest << endl;
    else
        cout << ans << endl;
    return 0;
}
